<!doctype html>
<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    
	<style type='text/css'>
		html { font-family:Helvetica; color:#222; }
		h1 { color:steelblue; font-size:24px; margin-top:24px; }
		button { margin:0 3px 10px; font-size:12px; }
		.logLine { border-bottom:1px solid #ccc; padding:4px 2px; font-family:courier; font-size:11px; }
	</style>

</head>

<body>
	<h1 align="middle">用户登陆 </h1>
	
	<div id='buttons'></div> 
	<div id='log'></div>

	<form action="H5.html">
		<p align="middle">用户名: <input id="name" type="text" name="username" style="height:28px"/><p/>
		<p align="middle">密  码:   <input id="pass" type="password" name="password" style="height:28px"/><p />
        <p align="middle"> <input id="buttonSubmit" type="submit"  value="登陆" style="width:180px;height:36px"/><p />
	</form>
    
	<script>
		window.onerror = function(err) {
			log('window.onerror: ' + err)
		}
	
		function connectWebViewJavascriptBridge(callback) {

			if (window.WebViewJavascriptBridge) {
				callback(WebViewJavascriptBridge)
			} else {
				document.addEventListener('WebViewJavascriptBridgeReady', function() {
				callback(WebViewJavascriptBridge)
				}, false)
			}
		}
	
		connectWebViewJavascriptBridge(function(bridge) {
			var uniqueId = 1

			bridge.init(function(message, responseCallback) {

              	document.getElementById('name').value = message.name;
				document.getElementById('pass').value = message.pass;
				var data = { 'Javascript Responds':'Wee!' }
				responseCallback(data)
			})

			bridge.registerHandler('testJavascriptHandler', function(data, responseCallback) {
				var responseData = { 'Javascript Says':'Right back atcha!' }
				responseCallback(responseData)
			})

   		 })
     
  	    document.getElementById("buttonSubmit").onclick= function objclick(){
			var username = document.getElementById('name').value;
			var password = document.getElementById('pass').value;
            var data = {'name':username,pass:password};
			// alert('JS sending message', data)
			window.WebViewJavascriptBridge.send(data, function(responseData) {
				// alert('JS got response', responseData)
			})
		}; 

	</script>
</body>
</html>
